package healththink



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Email)
class EmailTests {

	@Test
	void testEmail() {
		def email1 = HealthThink.getStaticEmail()
		mockForConstraintsTests(Email, [email1])
		def testEmail1 = new Email()
		assertFalse testEmail1.validate()
		assertEquals "nullable", testEmail1.errors["email"]

		 Email target = HealthThink.getStaticEmail()
		 assertNotNull("(error)Target Email Null", target)
		 assertNotNull("(error)Email Validation Was Not Successfull", target.validate())
		   
		 target = target.save(flush:true)
		 Email expected = Email.findById(target.id)
		   
		 assertNotNull("(error)Email Target was not saved", target)
		 assertNotNull("(error)Expected Email was null", expected)
		 assertEquals("(error)Target and Expected are not Equal", target, expected)
		   
		 target.delete(flush:true)
    }
}
